package leave.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import leave.dataaccess.DAOFactory;
import leave.exception.DataAccessException;

/**
 * Servlet implementation class LogInAdmin
 */
@WebServlet("/LogInAdmin")
public class LogInAdmin extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public LogInAdmin() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		
		
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String username = request.getParameter("username");
		String password = request.getParameter("password");
		
		HttpSession userSession = request.getSession(false);
		
		try {
			if(DAOFactory.getInstance().getAdminDAO().authenticate(username, password))
			{
				//DAOFactory.getInstance().getAdminDAO().
				//userSession.setAttribute("authenticatedUser", arg1);
			}
			else
			{
				
			}
		} catch (DataAccessException e) {
			e.printStackTrace();
		}
	}

}
